package com.ruoyi.subjectproctoring.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.subjectproctoring.domain.Subjectproctoring;
import com.ruoyi.subjectproctoring.service.ISubjectproctoringService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 监考需求Controller
 * 
 * @author tnx
 * @date 2024-11-24
 */
@RestController
@RequestMapping("/subjectproctoring/subjectproctoring")
public class SubjectproctoringController extends BaseController
{
    @Autowired
    private ISubjectproctoringService subjectproctoringService;

    /**
     * 查询监考需求列表
     */
    @PreAuthorize("@ss.hasPermi('subjectproctoring:subjectproctoring:list')")
    @GetMapping("/list")
    public TableDataInfo list(Subjectproctoring subjectproctoring)
    {
        startPage();
        List<Subjectproctoring> list = subjectproctoringService.selectSubjectproctoringList(subjectproctoring);
        return getDataTable(list);
    }

    /**
     * 导出监考需求列表
     */
    @PreAuthorize("@ss.hasPermi('subjectproctoring:subjectproctoring:export')")
    @Log(title = "监考需求", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Subjectproctoring subjectproctoring)
    {
        List<Subjectproctoring> list = subjectproctoringService.selectSubjectproctoringList(subjectproctoring);
        ExcelUtil<Subjectproctoring> util = new ExcelUtil<Subjectproctoring>(Subjectproctoring.class);
        util.exportExcel(response, list, "监考需求数据");
    }

    /**
     * 获取监考需求详细信息
     */
    @PreAuthorize("@ss.hasPermi('subjectproctoring:subjectproctoring:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(subjectproctoringService.selectSubjectproctoringById(id));
    }

    /**
     * 新增监考需求
     */
    @PreAuthorize("@ss.hasPermi('subjectproctoring:subjectproctoring:add')")
    @Log(title = "监考需求", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Subjectproctoring subjectproctoring)
    {
        return toAjax(subjectproctoringService.insertSubjectproctoring(subjectproctoring));
    }

    /**
     * 修改监考需求
     */
    @PreAuthorize("@ss.hasPermi('subjectproctoring:subjectproctoring:edit')")
    @Log(title = "监考需求", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Subjectproctoring subjectproctoring)
    {
        return toAjax(subjectproctoringService.updateSubjectproctoring(subjectproctoring));
    }

    /**
     * 删除监考需求
     */
    @PreAuthorize("@ss.hasPermi('subjectproctoring:subjectproctoring:remove')")
    @Log(title = "监考需求", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(subjectproctoringService.deleteSubjectproctoringByIds(ids));
    }
}
